<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/17 0017
 * Time: 下午 16:47
 */

namespace Home\Controller;
use Think\Controller;

class OnlineController extends Controller{
    protected  $model = null;
    public function __construct(){
        parent::__construct();
        $this->model = D('online');
    }

    //更改当前用户的所有聊天状态为离线 0
    public function update_user_online(){
        $userid = I('get.userid');
        $user_type = I('get.user_type');
        $aa = $this->model->upd_user_online($userid,$user_type);
        $this->ajaxReturn($user_type);

    }

    //给客服追加未读消息
    public function addto_kefu_wd_num(){
        $userid = I('get.userid');
        $kefuid = I('get.kefuid');
        $info = $this->model->update_addto_num($userid,$kefuid,'kefu_wd_num');

        $this->ajaxReturn($info);
    }

    //给客户追加未读消息
    public function addto_user_wd_num(){
        $userid = I('get.userid');
        $kefuid = I('get.kefuid');
        $info = $this->model->update_addto_num($userid,$kefuid,'user_wd_num');
        //dump($info);exit;
        $this->ajaxReturn($info);
    }

    //获取当前用户的所有未读消息数量
    public function get_wd_znum(){
        $userid = I('get.userid');
        $type = I('get.type');
        $info = $this->model->get_wd_znum($userid,$type);
        $this->ajaxReturn($info);
    }
}
